//
//  TableViewCell.m
//  Reader
//
//  Created by cjz on 2016/12/13.
//  Copyright © 2016年 wclwangchenglong. All rights reserved.
//

#import "TableViewCell.h"

@implementation TableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
    - (id)initWithImgs:(NSArray *)imgs
    {
        self = [super init];
        NSAssert(imgs.count < 4, @"cell内的图片不能多于3个！");
        NSMutableArray *arr = [NSMutableArray array];
        for (UIImage *img in imgs) {
            UIImageView *iv = [[UIImageView alloc] initWithImage:img];
            [self addSubview:iv];
            [arr addObject:iv];
        }
        self.imgs = arr;
        
        return self;
    }
    
    - (void)layoutSubviews
    {
        [super layoutSubviews];
        CGFloat edge = 15;
        CGFloat imgWidth = (self.frame.size.width - edge*4)/3.0;
        int i = 0;
        for (UIImageView *iv in self.imgs) {
            iv.frame = CGRectMake(edge + i*(imgWidth + edge), 8, imgWidth, 139 - 8*2 - 8);
            i++;
        }
    }
    
    @end



